import { IEditorConfig } from "@wangeditor/editor";

type InsertFnType = (url: string, alt: string, href: string) => void;

let config = {
    // placeholder: "请输入内容...",

    //鼠标选择编辑器内容后显示的菜单
    hoverbarKeys: {
        //选择文字内容
        text: {
            menuKeys: ["bold", "underline", "italic", "through", "clearStyle", "color", "bgColor", "fontSize"],
        },

        //选择图片
        image: {
            menuKeys: ["deleteImage", "editImage", "imageWidth30", "imageWidth50", "imageWidth100"],
        },
    },

    MENU_CONF: {},
} as Partial<IEditorConfig>;

//配置上传功能
config.MENU_CONF["uploadImage"] = {
    customUpload(file: File, insertFn: InsertFnType) {
        App.Upload(file)
            .then((res) => {
                insertFn(res.url, "", "");
            })
            .catch((err) => {
                console.log(err);
            });
    },
};

export default config as Partial<IEditorConfig>;
